package com.suli.multimedia.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.suli.multimedia.enums.Status;
import com.suli.multimedia.enums.TicketType;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;


/**
 * @author admin
 * @version 1.0 <br/>
 * <p style="font-family:SimSun;font-weight:bold">时间:<br/>2022/3/15 20:56</p>
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("publishTime",new Date() , metaObject);
        this.setFieldValByName("isDeleted",0 , metaObject);
        this.setFieldValByName("views",0 , metaObject);
        this.setFieldValByName("scenicTicketSale",0 , metaObject);
        this.setFieldValByName("scenicTicketVersion", 0, metaObject);
        this.setFieldValByName("scenicTicketStatus", TicketType.UnExpire, metaObject);
        this.setFieldValByName("scenicTicketPublishtime", new Date(), metaObject);
        this.setFieldValByName("ticketBuyTime", new Date(), metaObject);
        this.setFieldValByName("noteTime", new Date(), metaObject);
        this.setFieldValByName("ticketStatus", Status.UN_USE, metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
